package cn.felord.verse.configure;

import cn.felord.common.http.ExceptionHandleAdvice;
import cn.felord.common.http.RestBodyAdvice;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 异常处理和统一返回体配置
 */
@Configuration(proxyBeanMethods = false)
public class RestAdviceConfiguration {


    /**
     * Exception handle advice exception handle advice.
     *
     * @return the exception handle advice
     */
    @Bean
    public ExceptionHandleAdvice exceptionHandleAdvice() {
        return new ExceptionHandleAdvice();
    }

    /**
     * Rest body advice rest body advice.
     *
     * @return the rest body advice
     */
    @Bean
    public RestBodyAdvice restBodyAdvice(ObjectMapper objectMapper) {
        return new RestBodyAdvice(objectMapper);
    }
}
